<?php
/**
 * Desc:
 * User: hollowcg@foxmail.com
 * Date: 2019/5/25
 */

namespace app\common\widget;

use think\Db;

class Common
{
    public function getUserRoleSelect($default=''){
        $data = Db::name('userRole')->field('id,name')->select();
        $option = '';
        if (!empty($data)){
            foreach ($data as $k=>$v){
                if ($default == $v['id']){
                    $option .= "<option value='".$v['id']."' selected>".$v['name']."</option>";
                }else{
                    $option .= "<option value='".$v['id']."'>".$v['name']."</option>";
                }
            }
        }
        return $option;
    }
}